package com.example.allshengmedical.experimentnew.activity;

import java.io.File;
import java.lang.reflect.Type;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import android.R.integer;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Environment;
import android.text.Selection;
import android.text.Spannable;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import com.allsheng.widget.AllShengDialog;
import com.allsheng.widget.AllShengDialog.ClickListenerInterface;
import com.example.allshengmedical.R;
import com.example.allshengmedical.base.BaseActivity;
import com.example.allshengmedical.base.BaseApplication;
import com.example.allshengmedical.experimentnew.bean.FileBean;
import com.example.allshengmedical.experimentnew.bean.LayoutTableBean;
import com.example.allshengmedical.experimentnew.bean.SampleBean;
import com.example.allshengmedical.experimentnew.presenter.AbsoluteQuaLayoutPresenter;
import com.example.allshengmedical.experimentnew.view.IAbsoluteQuaLayoutView;
import com.example.allshengmedical.mainmenu.activity.MainMenuActivity;
import com.example.allshengmedical.util.ByAlert;
import com.example.allshengmedical.util.DragGridView;
import com.example.allshengmedical.util.FileManagerUtil;
import com.example.allshengmedical.util.SharedPreferencesUtils;
import com.example.allshengmedical.util.DragGridView.OnChanageListener;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.example.allshengmedical.util.LogUtil;

//新建绝对定量基因盘界面

public class AbsoluteQuaLayoutActivity extends BaseActivity implements
		IAbsoluteQuaLayoutView, OnClickListener {

	private ListView targetGenesLv, sampleLv;
	private LinearLayout sampleLine, standardLine, positiveLine, negativeLine,
			sampleLvLine, concentrationLine;
	private Button block1Btn, block2Btn;
	private int block = 1;
	private TextView blockUpTv, blockDownTv;
	private DragGridViewAdapter mSimple1Adapter;

	private AbsoluteQuaLayoutPresenter absoluteQuaLayoutPresenter;
	private ArrayList<LayoutTableBean> activityLayoutTableBeans;
	private TargetTableAdapter targetTableAdapter;
	private SampleAdapter sampleAdapter;
	private ArrayList<SampleBean> sampleBeans;
	private int samplePosition;

	private PopupWindow menuPopupWindow;
	private boolean menuboo;
	private Boolean targetSelected = false;
	private Boolean typeSelected = false;

	public List<HashMap<String, Object>> dataSourceListBlockToShow = new ArrayList<HashMap<String, Object>>();
	public List<HashMap<String, Object>> dataSourceListBlock1 = new ArrayList<HashMap<String, Object>>();
	public List<HashMap<String, Object>> dataSourceListBlock2 = new ArrayList<HashMap<String, Object>>();
	private DragGridView dragGridView;

	private Button inputBtn1, inputBtn2;
	private TextView singleTv, dilutionTv;

	private LinearLayout dilutionFactorLine, repetitionNumLine;

	private ArrayAdapter<String> dilution_arr_adapter;
	private ArrayAdapter<String> repetions_arr_adapter;
	private List<String> dilution_data_list;
	private List<String> repetions_data_list;

	private Spinner spinnerDilutionFactor, repetitionNum;
	private TextView initialConcentrationTv;

	private String standardType = "single";
	private String dilutionFactorStr = "1:2";
	private String repetitionNumStr = "1";

	private Boolean firstCreatList = false;

	private TextView resetTv;

	public static AbsoluteQuaLayoutActivity context;

	private FileManagerUtil fileManagerUtil;

	private Button allBtn;
	private TextView delTv;

	AllShengDialog allShengDialog;

	public static AbsoluteQuaLayoutActivity getInstence() {
		return context;
	}

	@Override
	protected int setcontent() {
		return R.layout.activity_new_absolutequalayout;
	}

	@Override
	protected void initView() {

		context = this;
		fileManagerUtil = new FileManagerUtil();

		// 获取上个页面的数据activityLayoutTableBeans！
		Intent intent = getIntent();
		activityLayoutTableBeans = (ArrayList<LayoutTableBean>) intent
				.getSerializableExtra("activityLayoutTableBeans");

		for (LayoutTableBean bean : activityLayoutTableBeans) {
			bean.setSelected(false);
		}
		activityLayoutTableBeans.get(0).setSelected(true);

		absoluteQuaLayoutPresenter = new AbsoluteQuaLayoutPresenter(this);

		absoluteQuaLayoutPresenter.initAppHead();
		absoluteQuaLayoutPresenter.initBottomView();
		initSampleLv();

		initTableLv();

		initDragGridView();

		spinnerDilutionFactor
				.setOnItemSelectedListener(new OnItemSelectedListener() {

					@Override
					public void onItemSelected(AdapterView<?> parent,
							View view, int position, long id) {
						switch (position) {
						case 0:
							dilutionFactorStr = "1:2";
							break;
						case 1:
							dilutionFactorStr = "1:3";
							break;

						case 2:
							dilutionFactorStr = "1:4";
							break;
						case 3:
							dilutionFactorStr = "1:5";
							break;
						case 4:
							dilutionFactorStr = "1:6";
							break;
						case 5:
							dilutionFactorStr = "1:7";
							break;
						case 6:
							dilutionFactorStr = "1:8";
							break;
						case 7:
							dilutionFactorStr = "1:9";
							break;

						case 8:
							dilutionFactorStr = "1:10";
							break;
						case 9:
							dilutionFactorStr = "*2";
							break;
						case 10:
							dilutionFactorStr = "*3";
							break;
						case 11:
							dilutionFactorStr = "*4";
							break;

						case 12:
							dilutionFactorStr = "*5";
							break;
						case 13:
							dilutionFactorStr = "*6";
							break;
						case 14:
							dilutionFactorStr = "*7";
							break;
						case 15:
							dilutionFactorStr = "*8";
							break;
						case 16:
							dilutionFactorStr = "*9";
							break;
						case 17:
							dilutionFactorStr = "*10";
							break;

						default:
							break;
						}

					}

					@Override
					public void onNothingSelected(AdapterView<?> parent) {

					}
				});
		repetitionNum.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int position, long id) {
				switch (position) {
				case 0:
					repetitionNumStr = "1";
					break;
				case 1:
					repetitionNumStr = "2";
					break;
				case 2:
					repetitionNumStr = "3";
					break;
				case 3:
					repetitionNumStr = "4";
					break;
				case 4:
					repetitionNumStr = "5";
					break;
				case 5:
					repetitionNumStr = "6";
					break;
				case 6:
					repetitionNumStr = "7";
					break;
				case 7:
					repetitionNumStr = "8";
					break;
				case 8:
					repetitionNumStr = "9";
					break;
				case 9:
					repetitionNumStr = "10";
					break;
				case 10:
					repetitionNumStr = "11";
					break;
				case 11:
					repetitionNumStr = "12";
					break;
				case 12:
					repetitionNumStr = "13";
					break;
				case 13:
					repetitionNumStr = "14";
					break;
				case 14:
					repetitionNumStr = "15";
					break;
				case 15:
					repetitionNumStr = "16";
					break;

				default:
					break;
				}

			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {

			}
		});

	}

	@Override
	protected void initData() {
		// dilution数据
		dilution_data_list = new ArrayList<String>();
		dilution_data_list.add("1:2");
		dilution_data_list.add("1:3");
		dilution_data_list.add("1:4");
		dilution_data_list.add("1:5");
		dilution_data_list.add("1:6");
		dilution_data_list.add("1:7");
		dilution_data_list.add("1:8");
		dilution_data_list.add("1:9");
		dilution_data_list.add("1:10");
		dilution_data_list.add("*2");
		dilution_data_list.add("*3");
		dilution_data_list.add("*4");
		dilution_data_list.add("*5");
		dilution_data_list.add("*6");
		dilution_data_list.add("*7");
		dilution_data_list.add("*8");
		dilution_data_list.add("*9");
		dilution_data_list.add("*10");

		// repetions数据
		repetions_data_list = new ArrayList<String>();
		repetions_data_list.add("1");
		repetions_data_list.add("2");
		repetions_data_list.add("3");
		repetions_data_list.add("4");
		repetions_data_list.add("5");
		repetions_data_list.add("6");
		repetions_data_list.add("7");
		repetions_data_list.add("8");
		repetions_data_list.add("9");
		repetions_data_list.add("10");
		repetions_data_list.add("11");
		repetions_data_list.add("12");
		repetions_data_list.add("13");
		repetions_data_list.add("14");
		repetions_data_list.add("15");
		repetions_data_list.add("16");

		// dilution适配器
		dilution_arr_adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, dilution_data_list);
		// repetion适配器
		repetions_arr_adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, repetions_data_list);

		// 设置样式
		dilution_arr_adapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		repetions_arr_adapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

		// setadpter
		spinnerDilutionFactor.setAdapter(dilution_arr_adapter);
		repetitionNum.setAdapter(repetions_arr_adapter);

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.sampleLine:
			absoluteQuaLayoutPresenter.selectSample();

			break;
		case R.id.standardLine:
			absoluteQuaLayoutPresenter.selectStandard();

			break;
		case R.id.positiveLine:
			absoluteQuaLayoutPresenter.selectPositive();

			break;
		case R.id.negativeLine:
			absoluteQuaLayoutPresenter.selectNegetive();

			break;

		case R.id.inputBtn1:
			absoluteQuaLayoutPresenter.inputSample();
			break;
		case R.id.inputBtn2:
			absoluteQuaLayoutPresenter.inputStandard();
			break;
		case R.id.block1Btn:
			block1Btn.setBackground(getResources().getDrawable(
					R.drawable.shape_darkblueblackframe));
			block2Btn.setBackground(getResources().getDrawable(
					R.drawable.shape_blackframe));
			blockUpTv.setText("A");
			blockDownTv.setText("B");
			block = 1;
			for (int i = 0; i < dataSourceListBlock1.size(); i++) {
				dataSourceListBlock1.get(i).put("item_selected", false);

			}
			for (int i = 0; i < dataSourceListBlock2.size(); i++) {
				dataSourceListBlock2.get(i).put("item_selected", false);
			}
			dataSourceListBlockToShow.clear();
			dataSourceListBlockToShow.addAll(dataSourceListBlock1);
			mSimple1Adapter.notifyDataSetChanged();

			// mSimple1Adapter.changeList(dataSourceListBlockToShow);
			// mSimple1Adapter.notifyDataSetChanged();

			// mSimple1Adapter = new DragGridViewAdapter(dataSourceListBlock1);
			// dragGridView.setAdapter(mSimple1Adapter);
			break;
		case R.id.block2Btn:
			block1Btn.setBackground(getResources().getDrawable(
					R.drawable.shape_blackframe));
			block2Btn.setBackground(getResources().getDrawable(
					R.drawable.shape_darkblueblackframe));
			blockUpTv.setText("C");
			blockDownTv.setText("D");
			block = 2;
			for (int i = 0; i < dataSourceListBlock1.size(); i++) {
				dataSourceListBlock1.get(i).put("item_selected", false);
			}
			for (int i = 0; i < dataSourceListBlock2.size(); i++) {
				dataSourceListBlock2.get(i).put("item_selected", false);
			}
			dataSourceListBlockToShow.clear();
			dataSourceListBlockToShow.addAll(dataSourceListBlock2);
			mSimple1Adapter.notifyDataSetChanged();

			// mSimple1Adapter.changeList(dataSourceListBlockToShow);
			// mSimple1Adapter.notifyDataSetChanged();

			// mSimple1Adapter = new DragGridViewAdapter(dataSourceListBlock2);
			// dragGridView.setAdapter(mSimple1Adapter);
			break;
		case R.id.singleTv:
			singleTv.setBackground(getResources().getDrawable(R.color.darkBlue));
			dilutionTv.setBackground(getResources().getDrawable(R.color.white));
			standardType = "single";
			dilutionFactorLine.setVisibility(View.INVISIBLE);
			repetitionNumLine.setVisibility(View.INVISIBLE);

			break;
		case R.id.dilutionTv:
			dilutionTv.setBackground(getResources().getDrawable(
					R.color.darkBlue));
			singleTv.setBackground(getResources().getDrawable(R.color.white));
			standardType = "dilution";
			dilutionFactorLine.setVisibility(View.VISIBLE);
			repetitionNumLine.setVisibility(View.VISIBLE);
			break;
		case R.id.initialConcentrationTv:
			numberKeyBoardPopupWindow(v);
			break;
		case R.id.blockUpTv:
			if (block == 1) {
				for (int i = 0; i < 8; i++) {

					// 选中状态
					dataSourceListBlock1.get(i).put("item_selected", true);
					mSimple1Adapter.notifyDataSetChanged();

				}
			} else if (block == 2) {
				for (int i = 0; i < 8; i++) {
					// 选中状态
					dataSourceListBlock2.get(i).put("item_selected", true);
					mSimple1Adapter.notifyDataSetChanged();

				}
			}
			break;
		case R.id.blockDownTv:
			if (block == 1) {
				for (int i = 8; i < 16; i++) {

					// 选中状态
					dataSourceListBlock1.get(i).put("item_selected", true);
					mSimple1Adapter.notifyDataSetChanged();

				}
			} else if (block == 2) {
				for (int i = 8; i < 16; i++) {
					// 选中状态
					dataSourceListBlock2.get(i).put("item_selected", true);
					mSimple1Adapter.notifyDataSetChanged();

				}
			}
			break;
		case R.id.delTv:
			if (block == 1) {
				Boolean selectOrNot = false;
				for (HashMap<String, Object> map : dataSourceListBlock1) {
					if ((Boolean) map.get("item_selected")) {
						selectOrNot = true;
					}
				}

				if (selectOrNot) {

				} else {
					final AllShengDialog allShengDialog = new AllShengDialog(
							AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！",
							"OK");
					allShengDialog.show();
					allShengDialog
							.setClicklistener(new ClickListenerInterface() {

								@Override
								public void OK() {
									// TODO Auto-generated method stub
									allShengDialog.dismiss();
									return;
								}

								@Override
								public void Cancle() {
									// TODO Auto-generated method stub
									allShengDialog.dismiss();
								}

							});

					// ByAlert.alert("请至少选中一个基因盘！");
					// return;
				}

			} else if (block == 2) {
				Boolean selectOrNot = false;
				for (HashMap<String, Object> map : dataSourceListBlock2) {
					if ((Boolean) map.get("item_selected")) {
						selectOrNot = true;
					}
				}

				if (selectOrNot) {

				} else {
					final AllShengDialog allShengDialog = new AllShengDialog(
							AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！",
							"OK");
					allShengDialog.show();
					allShengDialog
							.setClicklistener(new ClickListenerInterface() {

								@Override
								public void OK() {
									// TODO Auto-generated method stub
									allShengDialog.dismiss();
									return;
								}

								@Override
								public void Cancle() {
									// TODO Auto-generated method stub
									allShengDialog.dismiss();
								}

							});

					// ByAlert.alert("请至少选中一个基因盘！");
					// return;
				}

			}

			if (block == 1) {
				for (final HashMap<String, Object> map : dataSourceListBlock1) {
					if ((Boolean) map.get("item_selected")) {

						// HashMap<String, Object> itemHashMap = new
						// HashMap<String, Object>();
						// 颜色
						map.put("item_image", "");
						// 名字
						map.put("item_text", "1Block");
						// 选中状态
						map.put("item_selected", false);
						map.put("item_type", null);

					}
					dataSourceListBlockToShow.clear();
					dataSourceListBlockToShow.addAll(dataSourceListBlock1);
					mSimple1Adapter.notifyDataSetChanged();
					typeSelected = false;
				}
			} else if (block == 2) {
				for (final HashMap<String, Object> map : dataSourceListBlock2) {
					if ((Boolean) map.get("item_selected")) {
						// HashMap<String, Object> itemHashMap = new
						// HashMap<String, Object>();
						// 颜色
						map.put("item_image", "");
						// 名字
						map.put("item_text", "1Block");
						// 选中状态
						map.put("item_selected", false);
						map.put("item_type", null);
						// dataSourceListBlock1.add(itemHashMap);
					}
					dataSourceListBlockToShow.clear();
					dataSourceListBlockToShow.addAll(dataSourceListBlock2);
					mSimple1Adapter.notifyDataSetChanged();
					typeSelected = false;
				}
			}

			break;

		case R.id.resetTv:
			dataSourceListBlock1.clear();
			dataSourceListBlock2.clear();
			for (int i = 0; i < 16; i++) {
				HashMap<String, Object> itemHashMap = new HashMap<String, Object>();
				// 颜色
				itemHashMap.put("item_image", "");
				// 名字
				itemHashMap.put("item_text", "1Block" + Integer.toString(i));
				// 选中状态
				itemHashMap.put("item_selected", false);

				dataSourceListBlock1.add(itemHashMap);

			}
			for (int i = 0; i < 16; i++) {
				HashMap<String, Object> itemHashMap = new HashMap<String, Object>();
				// 颜色
				itemHashMap.put("item_image", "");
				// 名字
				itemHashMap.put("item_text", "2Block " + Integer.toString(i));
				// 选中状态
				itemHashMap.put("item_selected", false);

				dataSourceListBlock2.add(itemHashMap);
			}
			dataSourceListBlockToShow.clear();
			if (block == 1) {
				dataSourceListBlockToShow.addAll(dataSourceListBlock1);
			} else {
				dataSourceListBlockToShow.addAll(dataSourceListBlock2);
			}
			mSimple1Adapter.notifyDataSetChanged();

			// if (block == 1) {
			//
			// for (int i = 0; i < 16; i++) {
			//
			// // 颜色
			// dataSourceListBlock1.get(i).put("item_image", "");
			// // 名字
			// dataSourceListBlock1.get(i).put("item_text",
			// "1Block" + Integer.toString(i));
			//
			// // 选中状态
			// dataSourceListBlock1.get(i).put("item_selected", false);
			// // 滞空
			// dataSourceListBlock1.get(i).put("item_null", true);
			//
			// dataSourceListBlock1.get(i).put("item_type", "");
			// }
			//
			// dataSourceListBlockToShow = dataSourceListBlock1;
			//
			// mSimple1Adapter.notifyDataSetChanged();
			//
			// } else if (block == 2) {
			// for (int i = 0; i < 16; i++) {
			//
			// // 颜色
			// dataSourceListBlock2.get(i).put("item_image", "");
			// // 名字
			// dataSourceListBlock2.get(i).put("item_text",
			// "1Block" + Integer.toString(i));
			//
			// // 选中状态
			// dataSourceListBlock2.get(i).put("item_selected", false);
			// // 滞空
			// dataSourceListBlock2.get(i).put("item_null", true);
			// dataSourceListBlock2.get(i).put("item_type", "");
			//
			// }
			// dataSourceListBlockToShow = dataSourceListBlock2;
			//
			// mSimple1Adapter.notifyDataSetChanged();
			//
			// }
			break;
		case R.id.allBtn:

			for (int i = 0; i < 16; i++) {

				// 颜色
				// dataSourceListBlock1.get(i).put("item_image", "");
				// // 名字
				// dataSourceListBlock1.get(i).put("item_text", "1Block" +
				// Integer.toString(i));

				// 选中状态
				dataSourceListBlock1.get(i).put("item_selected", true);
				// 滞空
				// dataSourceListBlock1.get(i).put("item_null", true);

				// dataSourceListBlock1.get(i).put("item_type", "");
			}

			for (int i = 0; i < 16; i++) {

				// 颜色
				// dataSourceListBlock2.get(i).put("item_image", "");
				// // 名字
				// dataSourceListBlock2.get(i).put("item_text", "1Block" +
				// Integer.toString(i));

				// 选中状态
				dataSourceListBlock2.get(i).put("item_selected", true);
				// 滞空
				// dataSourceListBlock2.get(i).put("item_null", true);
				// dataSourceListBlock2.get(i).put("item_type", "");

			}
			mSimple1Adapter.notifyDataSetChanged();
			break;
		default:
			break;
		}

	}

	@Override
	public void initAppHead() {
		setActionBar();
		setSystemTime();

	}

	@Override
	public void initBottomView() {
		setBottomView();

	}

	@Override
	public void selectTargetGenes(int position, BaseAdapter adapter) {
		if (typeSelected) {
			for (int i = 0; i < activityLayoutTableBeans.size(); i++) {

				if (activityLayoutTableBeans.get(i).isSelected()) {
					activityLayoutTableBeans.get(i).setSelected(false);
				}

			}
			activityLayoutTableBeans.get(position).setSelected(true);
			adapter.notifyDataSetChanged();
		} else {
			for (int i = 0; i < activityLayoutTableBeans.size(); i++) {

				if (activityLayoutTableBeans.get(i).isSelected()) {
					activityLayoutTableBeans.get(i).setSelected(false);
				}

			}
			activityLayoutTableBeans.get(position).setSelected(true);
			adapter.notifyDataSetChanged();
		}

	}

	@Override
	public void selectSample() {
		ifTargetSelected();

		if (targetSelected) {
			sampleLine.setBackground(getResources().getDrawable(
					R.color.darkBlue));
			standardLine.setBackground(getResources()
					.getDrawable(R.color.white));
			positiveLine.setBackground(getResources()
					.getDrawable(R.color.white));
			negativeLine.setBackground(getResources()
					.getDrawable(R.color.white));
			sampleLvLine.setVisibility(View.VISIBLE);
			concentrationLine.setVisibility(View.GONE);
			typeSelected = true;

			// 解決一个bug 需要点击两次sample 右边的simpleView才会出现footView
			// if (!firstCreatList) {
			//
			// firstCreatList=true;
			// }
			// initSampleLv();

			// sampleBeans.clear();
			// for (LayoutTableBean bean : activityLayoutTableBeans) {
			// if (bean.isSelected()) {
			// sampleBeans = bean.getSampleBeans();
			// }
			// }
			// sampleAdapter.notifyDataSetChanged();

			// sampleAdapter = new SampleAdapter(sampleBeans);
			//
			// sampleLv.setAdapter(sampleAdapter);

		} else {
			final AllShengDialog allShengDialog = new AllShengDialog(
					AbsoluteQuaLayoutActivity.this, "", "Target需要先被选中！", "OK");
			allShengDialog.setClicklistener(new ClickListenerInterface() {

				@Override
				public void OK() {
					// TODO Auto-generated method stub
					allShengDialog.dismiss();
				}

				@Override
				public void Cancle() {
					// TODO Auto-generated method stub
					allShengDialog.dismiss();
				}

			});
			allShengDialog.show();
			// ByAlert.alert("Target需要先被选中！");
		}

	}

	@Override
	public void selectStandard() {
		ifTargetSelected();

		if (targetSelected) {
			sampleLine.setBackground(getResources().getDrawable(R.color.white));
			standardLine.setBackground(getResources().getDrawable(
					R.color.darkBlue));
			positiveLine.setBackground(getResources()
					.getDrawable(R.color.white));
			negativeLine.setBackground(getResources()
					.getDrawable(R.color.white));
			sampleLvLine.setVisibility(View.GONE);

			singleTv.setBackground(getResources().getDrawable(R.color.darkBlue));
			dilutionTv.setBackground(getResources().getDrawable(R.color.white));
			concentrationLine.setVisibility(View.VISIBLE);
			dilutionFactorLine.setVisibility(View.INVISIBLE);
			repetitionNumLine.setVisibility(View.INVISIBLE);
			typeSelected = false;
		} else {
			final AllShengDialog allShengDialog = new AllShengDialog(
					AbsoluteQuaLayoutActivity.this, "", "Target需要先被选中！", "OK");
			allShengDialog.setClicklistener(new ClickListenerInterface() {

				@Override
				public void OK() {
					// TODO Auto-generated method stub
					allShengDialog.dismiss();
				}

				@Override
				public void Cancle() {
					// TODO Auto-generated method stub
					allShengDialog.dismiss();
				}

			});
			allShengDialog.show();
			// ByAlert.alert("Target需要先被选中！");
		}

	}

	@Override
	public void selectPositive() {
		// 需要先选中基因盘
		standardLine.setBackground(getResources().getDrawable(R.color.white));
		sampleLine.setBackground(getResources().getDrawable(R.color.white));
		sampleLvLine.setVisibility(View.GONE);
		concentrationLine.setVisibility(View.GONE);

		if (block == 1) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock1) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}
			Boolean selectedBoolean = false;
			for (LayoutTableBean bean : activityLayoutTableBeans) {
				if (bean.isSelected()) {
					selectedBoolean = true;
				} else {

				}
			}

			if (selectedBoolean) {

			} else {
				ByAlert.alert(getString(R.string.absolutelayout_choseatarget));
				return;
			}
			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				// return;

			}
		} else if (block == 2) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock2) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}

			Boolean selectedBoolean = false;
			for (LayoutTableBean bean : activityLayoutTableBeans) {
				if (bean.isSelected()) {
					selectedBoolean = true;
				} else {

				}
			}

			if (selectedBoolean) {

			} else {
				ByAlert.alert(getString(R.string.absolutelayout_choseatarget));
				return;
			}
			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				// return;
			}

		}
		String color = "";
		for (LayoutTableBean layoutTableBean : activityLayoutTableBeans) {
			if (layoutTableBean.isSelected()) {
				color = layoutTableBean.getColor() + "";
			}
		}

		if (block == 1) {
			for (final HashMap<String, Object> map : dataSourceListBlock1) {
				if ((Boolean) map.get("item_selected")) {

					map.put("item_text", "Pos.");
					map.put("item_image", color + "");
					map.put("item_selected", false);
					map.put("item_type", "positive");
					for (LayoutTableBean bean : activityLayoutTableBeans) {
						if (bean.isSelected()) {
							map.put("item_aisle", bean.getAisle());
						}
					}

				}
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock1);
				mSimple1Adapter.notifyDataSetChanged();
				typeSelected = false;
			}
		} else if (block == 2) {
			for (final HashMap<String, Object> map : dataSourceListBlock2) {
				if ((Boolean) map.get("item_selected")) {
					map.put("item_text", "Pos.");
					map.put("item_image", color + "");
					map.put("item_selected", false);
					map.put("item_type", "positive");
					for (LayoutTableBean bean : activityLayoutTableBeans) {
						if (bean.isSelected()) {
							map.put("item_aisle", bean.getAisle());
						}
					}
				}
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock2);
				mSimple1Adapter.notifyDataSetChanged();
				typeSelected = false;
			}
		}

	}

	@Override
	public void selectNegetive() {
		standardLine.setBackground(getResources().getDrawable(R.color.white));
		sampleLine.setBackground(getResources().getDrawable(R.color.white));
		sampleLvLine.setVisibility(View.GONE);
		concentrationLine.setVisibility(View.GONE);

		if (block == 1) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock1) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}
			Boolean selectedBoolean = false;
			for (LayoutTableBean bean : activityLayoutTableBeans) {
				if (bean.isSelected()) {
					selectedBoolean = true;
				} else {

				}
			}

			if (selectedBoolean) {

			} else {
				ByAlert.alert(getString(R.string.absolutelayout_choseatarget));
				return;
			}

			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				// return;
			}
		} else if (block == 2) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock2) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}

			Boolean selectedBoolean = false;
			for (LayoutTableBean bean : activityLayoutTableBeans) {
				if (bean.isSelected()) {
					selectedBoolean = true;
				} else {

				}
			}

			if (selectedBoolean) {

			} else {
				ByAlert.alert(getString(R.string.absolutelayout_choseatarget));
				return;
			}
			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				// return;
			}

		}
		String color = "";
		for (LayoutTableBean layoutTableBean : activityLayoutTableBeans) {
			if (layoutTableBean.isSelected()) {
				color = layoutTableBean.getColor() + "";
			}
		}

		if (block == 1) {
			for (final HashMap<String, Object> map : dataSourceListBlock1) {
				if ((Boolean) map.get("item_selected")) {

					map.put("item_text", "Neg.");
					map.put("item_image", color + "");
					map.put("item_selected", false);
					map.put("item_type", "negative");
					for (LayoutTableBean bean : activityLayoutTableBeans) {
						if (bean.isSelected()) {
							map.put("item_aisle", bean.getAisle());
						}
					}

				}
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock1);
				mSimple1Adapter.notifyDataSetChanged();
				typeSelected = false;
			}
		} else if (block == 2) {
			for (final HashMap<String, Object> map : dataSourceListBlock2) {
				if ((Boolean) map.get("item_selected")) {

					map.put("item_text", "Neg.");
					map.put("item_image", color + "");
					map.put("item_selected", false);
					map.put("item_type", "negative");
					for (LayoutTableBean bean : activityLayoutTableBeans) {
						if (bean.isSelected()) {
							map.put("item_aisle", bean.getAisle());
						}
					}
				}
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock2);
				mSimple1Adapter.notifyDataSetChanged();
				typeSelected = false;
			}
		}

	}

	@Override
	public void inputSample() {

		if (block == 1) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock1) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}
			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				// return;
			}
		} else if (block == 2) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock2) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}
			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				// return;
			}

		}
		Boolean selectOrNot = false;
		for (int i = 0; i < sampleBeans.size(); i++) {
			if (sampleBeans.get(i).getSelected()) {
				selectOrNot = true;
			}
		}
		if (selectOrNot) {
			String color = "";
			for (LayoutTableBean layoutTableBean : activityLayoutTableBeans) {
				if (layoutTableBean.isSelected()) {
					color = layoutTableBean.getColor() + "";
				}
			}

			if (block == 1) {
				for (int i = 0; i < sampleBeans.size(); i++) {
					if (sampleBeans.get(i).getSelected()) {

						for (HashMap<String, Object> map : dataSourceListBlock1) {
							if ((Boolean) map.get("item_selected")) {
								map.put("item_text", sampleBeans.get(i)
										.getSampleName());
								map.put("item_image", color + "");
								map.put("item_selected", false);
								map.put("item_type", "sample");
								for (LayoutTableBean bean : activityLayoutTableBeans) {
									if (bean.isSelected()) {
										map.put("item_aisle", bean.getAisle());
									}
								}

							}
						}
					}
					dataSourceListBlockToShow.clear();
					dataSourceListBlockToShow.addAll(dataSourceListBlock1);
					mSimple1Adapter.notifyDataSetChanged();
				}
			} else if (block == 2) {
				for (int i = 0; i < sampleBeans.size(); i++) {
					if (sampleBeans.get(i).getSelected()) {

						for (HashMap<String, Object> map : dataSourceListBlock2) {
							if ((Boolean) map.get("item_selected")) {
								map.put("item_text", sampleBeans.get(i)
										.getSampleName());
								map.put("item_image", color + "");
								map.put("item_selected", false);
								map.put("item_type", "sample");
								for (LayoutTableBean bean : activityLayoutTableBeans) {
									if (bean.isSelected()) {
										map.put("item_aisle", bean.getAisle());
									}
								}

							}
						}
					}
				}
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock2);
				mSimple1Adapter.notifyDataSetChanged();

			}
		} else {
			final AllShengDialog allShengDialog = new AllShengDialog(
					AbsoluteQuaLayoutActivity.this, "", "请至少选中一个样品！", "OK");
			allShengDialog.show();
			allShengDialog.setClicklistener(new ClickListenerInterface() {

				@Override
				public void OK() {
					// TODO Auto-generated method stub
					allShengDialog.dismiss();
					return;
				}

				@Override
				public void Cancle() {
					// TODO Auto-generated method stub
					allShengDialog.dismiss();
				}

			});

			// ByAlert.alert("请添加或者选中一个样品");
		}

	}

	@Override
	public void reset() {
		// TODO Auto-generated method stub

	}

	@Override
	public void selectInitConcentration() {
		// TODO Auto-generated method stub

	}

	@Override
	public void selectNumberOfRepitions() {
		// TODO Auto-generated method stub

	}

	@Override
	public void dilutionFactor() {
		// TODO Auto-generated method stub

	}

	@Override
	public void inputStandard() {
		if (block == 1) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock1) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}
			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				return;
			}
		} else if (block == 2) {
			Boolean selectOrNot = false;
			for (HashMap<String, Object> map : dataSourceListBlock2) {
				if ((Boolean) map.get("item_selected")) {
					selectOrNot = true;
				}
			}
			if (selectOrNot) {

			} else {
				final AllShengDialog allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this, "", "请至少选中一个基因盘！", "OK");
				allShengDialog.show();
				allShengDialog.setClicklistener(new ClickListenerInterface() {

					@Override
					public void OK() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
						return;
					}

					@Override
					public void Cancle() {
						// TODO Auto-generated method stub
						allShengDialog.dismiss();
					}

				});

				// ByAlert.alert("请至少选中一个基因盘！");
				return;
			}

		}
		String color = "";
		for (LayoutTableBean layoutTableBean : activityLayoutTableBeans) {
			if (layoutTableBean.isSelected()) {
				color = layoutTableBean.getColor() + "";
			}
		}

		// repetion的标记位
		int repetionNum = 0;
		float showNameString = Float.parseFloat(initialConcentrationTv
				.getText() + "");

		DecimalFormat df = new DecimalFormat();
		String style = "0.00E00";
		df.applyPattern(style);

		if (block == 1) {
			for (final HashMap<String, Object> map : dataSourceListBlock1) {
				if ((Boolean) map.get("item_selected")) {

					if ("single".equals(standardType)) {
						map.put("item_text",
								"St."
										+ df.format(Double
												.parseDouble(initialConcentrationTv
														.getText() + "")));
						map.put("item_image", color + "");
						map.put("item_selected", false);
						map.put("item_type", "standard");
						map.put("standard_type", "single");
						map.put("concentration",
								initialConcentrationTv.getText());
						for (LayoutTableBean bean : activityLayoutTableBeans) {
							if (bean.isSelected()) {
								map.put("item_aisle", bean.getAisle());
							}
						}
					} else if ("dilution".equals(standardType)) {
						String dilu = spinnerDilutionFactor.getSelectedItem()
								+ "";
						int repetion = Integer.parseInt(repetitionNum
								.getSelectedItem() + "");

						if (repetionNum < repetion) {
							map.put("item_text",
									"St."
											+ df.format(Double
													.parseDouble(showNameString
															+ "")));
							map.put("item_image", color + "");
							map.put("item_selected", false);
							map.put("item_type", "standard");
							map.put("standard_type", "dilution");
							map.put("concentration",
									initialConcentrationTv.getText());
							map.put("standard_type", "dilution");
							map.put("dilution_factor", dilutionFactorStr);
							map.put("number_repetion", repetitionNumStr);
							for (LayoutTableBean bean : activityLayoutTableBeans) {
								if (bean.isSelected()) {
									map.put("item_aisle", bean.getAisle());
								}
							}

							repetionNum++;
						} else {
							if (dilu.equals("1:2")) {
								showNameString = showNameString / 2;
							} else if (dilu.equals("1:3")) {
								showNameString = showNameString / 3;
							} else if (dilu.equals("1:4")) {
								showNameString = showNameString / 4;
							} else if (dilu.equals("1:5")) {
								showNameString = showNameString / 5;
							} else if (dilu.equals("1:6")) {
								showNameString = showNameString / 6;
							} else if (dilu.equals("1:7")) {
								showNameString = showNameString / 7;
							} else if (dilu.equals("1:8")) {
								showNameString = showNameString / 8;
							} else if (dilu.equals("1:9")) {
								showNameString = showNameString / 9;
							} else if (dilu.equals("1:10")) {
								showNameString = showNameString / 10;
							} else if (dilu.equals("*2")) {
								showNameString = showNameString * 2;
							} else if (dilu.equals("*3")) {
								showNameString = showNameString * 3;
							} else if (dilu.equals("*4")) {
								showNameString = showNameString * 4;
							} else if (dilu.equals("*5")) {
								showNameString = showNameString * 5;
							} else if (dilu.equals("*6")) {
								showNameString = showNameString * 6;
							} else if (dilu.equals("*7")) {
								showNameString = showNameString * 7;
							} else if (dilu.equals("*8")) {
								showNameString = showNameString * 8;
							} else if (dilu.equals("*9")) {
								showNameString = showNameString * 9;
							} else if (dilu.equals("*10")) {
								showNameString = showNameString * 10;
							}

							map.put("item_text",
									"St."
											+ df.format(Double
													.parseDouble(showNameString
															+ "")));
							map.put("item_image", color + "");
							map.put("item_selected", false);
							map.put("item_type", "standard");
							map.put("standard_type", "dilution");
							map.put("concentration",
									initialConcentrationTv.getText());
							map.put("standard_type", "dilution");
							map.put("dilution_factor", dilutionFactorStr);
							map.put("number_repetion", repetitionNumStr);
							for (LayoutTableBean bean : activityLayoutTableBeans) {
								if (bean.isSelected()) {
									map.put("item_aisle", bean.getAisle());
								}
							}

							repetionNum = 1;
						}

					}

				}
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock1);
				mSimple1Adapter.notifyDataSetChanged();
			}
		} else if (block == 2) {
			for (final HashMap<String, Object> map : dataSourceListBlock2) {
				if ((Boolean) map.get("item_selected")) {

					if ("single".equals(standardType)) {
						map.put("item_text",
								"St."
										+ df.format(Double
												.parseDouble(initialConcentrationTv
														.getText() + "")));
						map.put("item_image", color + "");
						map.put("item_selected", false);
						map.put("item_type", "standard");
						map.put("standard_type", "single");
						map.put("concentration",
								initialConcentrationTv.getText());
						for (LayoutTableBean bean : activityLayoutTableBeans) {
							if (bean.isSelected()) {
								map.put("item_aisle", bean.getAisle());
							}
						}
					} else if ("dilution".equals(standardType)) {
						String dilu = spinnerDilutionFactor.getSelectedItem()
								+ "";
						int repetion = Integer.parseInt(repetitionNum
								.getSelectedItem() + "");

						if (repetionNum < repetion) {
							map.put("item_text",
									"St."
											+ df.format(Double
													.parseDouble(showNameString
															+ "")));
							map.put("item_image", color + "");
							map.put("item_selected", false);
							map.put("item_type", "standard");
							map.put("standard_type", "dilution");
							map.put("concentration",
									initialConcentrationTv.getText());
							map.put("standard_type", "dilution");
							map.put("dilution_factor", dilutionFactorStr);
							map.put("number_repetion", repetitionNumStr);
							for (LayoutTableBean bean : activityLayoutTableBeans) {
								if (bean.isSelected()) {
									map.put("item_aisle", bean.getAisle());
								}
							}

							repetionNum++;
						} else {
							if (dilu.equals("1:2")) {
								showNameString = showNameString / 2;
							} else if (dilu.equals("1:3")) {
								showNameString = showNameString / 3;
							} else if (dilu.equals("1:4")) {
								showNameString = showNameString / 4;
							} else if (dilu.equals("1:5")) {
								showNameString = showNameString / 5;
							} else if (dilu.equals("1:6")) {
								showNameString = showNameString / 6;
							} else if (dilu.equals("1:7")) {
								showNameString = showNameString / 7;
							} else if (dilu.equals("1:8")) {
								showNameString = showNameString / 8;
							} else if (dilu.equals("1:9")) {
								showNameString = showNameString / 9;
							} else if (dilu.equals("1:10")) {
								showNameString = showNameString / 10;
							} else if (dilu.equals("*2")) {
								showNameString = showNameString * 2;
							} else if (dilu.equals("*3")) {
								showNameString = showNameString * 3;
							} else if (dilu.equals("*4")) {
								showNameString = showNameString * 4;
							} else if (dilu.equals("*5")) {
								showNameString = showNameString * 5;
							} else if (dilu.equals("*6")) {
								showNameString = showNameString * 6;
							} else if (dilu.equals("*7")) {
								showNameString = showNameString * 7;
							} else if (dilu.equals("*8")) {
								showNameString = showNameString * 8;
							} else if (dilu.equals("*9")) {
								showNameString = showNameString * 9;
							} else if (dilu.equals("*10")) {
								showNameString = showNameString * 10;
							}

							map.put("item_text",
									"St."
											+ df.format(Double
													.parseDouble(showNameString
															+ "")));
							map.put("item_image", color + "");
							map.put("item_selected", false);
							map.put("item_type", "standard");
							map.put("standard_type", "dilution");
							map.put("concentration",
									initialConcentrationTv.getText());
							map.put("standard_type", "dilution");
							map.put("dilution_factor", dilutionFactorStr);
							map.put("number_repetion", repetitionNumStr);
							for (LayoutTableBean bean : activityLayoutTableBeans) {
								if (bean.isSelected()) {
									map.put("item_aisle", bean.getAisle());
								}
							}

							repetionNum = 1;
						}

					}

				}
				dataSourceListBlockToShow.clear();
				dataSourceListBlockToShow.addAll(dataSourceListBlock2);
				mSimple1Adapter.notifyDataSetChanged();
			}
		}
		// ByAlert.alert(dataSourceListBlock1.get(0).get("dilution_factor") +
		// "");
		// ByAlert.alert(dataSourceListBlock2.get(0).get("dilution_factor") +
		// "");

	}

	public class TargetTableAdapter extends BaseAdapter {

		private ArrayList<LayoutTableBean> layoutTableBeans;

		public TargetTableAdapter(ArrayList<LayoutTableBean> layoutTableBeans) {
			super();
			this.layoutTableBeans = layoutTableBeans;
		}

		class ViewHolder {
			TextView numTv, targetNameTv, dyesNameTv;

			ImageView colorIv;
			LinearLayout line;

		}

		@Override
		public int getCount() {
			return layoutTableBeans != null ? layoutTableBeans.size() : 0;
		}

		@Override
		public Object getItem(int position) {
			return layoutTableBeans != null ? layoutTableBeans.get(position)
					: null;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(final int position, View convertView,
				ViewGroup parent) {
			final ViewHolder holder;
			if (convertView == null) {
				holder = new ViewHolder();
				convertView = LayoutInflater.from(
						AbsoluteQuaLayoutActivity.this).inflate(
						R.layout.item_layout2_targetgenes, null);
				holder.colorIv = (ImageView) convertView
						.findViewById(R.id.colorIv);
				holder.dyesNameTv = (TextView) convertView
						.findViewById(R.id.dyesNameTv);
				holder.numTv = (TextView) convertView.findViewById(R.id.numTv);

				holder.targetNameTv = (TextView) convertView
						.findViewById(R.id.targetNameTv);

				holder.line = (LinearLayout) convertView
						.findViewById(R.id.line);
				convertView.setTag(holder);
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			if (activityLayoutTableBeans.get(position).isSelected()) {
				holder.line.setBackground(getResources().getDrawable(
						R.color.darkBlue));
			} else {
				holder.line.setBackground(getResources().getDrawable(
						R.color.white));
			}

			holder.line.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {

					absoluteQuaLayoutPresenter.selectTargetGenes(position,
							targetTableAdapter);
					// if (typeSelected == true) {
					// initSampleLv();
					// }

				}
			});

			holder.numTv.setText(position + 1 + "");
			holder.targetNameTv.setText(layoutTableBeans.get(position)
					.getTarget());

			holder.dyesNameTv.setText(layoutTableBeans.get(position)
					.getFluorescentDyes());

			switch (layoutTableBeans.get(position).getColor()) {
			case 11:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_one_one));
				break;
			case 12:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_one_two));
				break;
			case 13:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_one_three));

				break;
			case 14:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_one_four));

				break;
			case 15:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_one_five));

				break;
			case 16:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_one_six));

				break;
			case 21:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_two_one));
				break;
			case 22:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_two_two));
				break;
			case 23:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_two_three));
				break;
			case 24:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_two_four));
				break;
			case 25:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_two_five));
				break;
			case 26:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_two_six));
				break;
			case 31:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_three_one));
				break;
			case 32:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_three_two));
				break;
			case 33:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_three_three));
				break;
			case 34:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_three_four));
				break;
			case 35:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_three_five));
				break;
			case 36:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_three_six));
				break;

			case 41:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_four_one));
				break;
			case 42:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_four_two));
				break;
			case 43:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_four_three));
				break;
			case 44:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_four_four));
				break;
			case 45:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_four_five));
				break;
			case 46:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_four_six));
				break;
			case 51:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_five_one));
				break;
			case 52:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_five_two));
				break;
			case 53:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_five_three));
				break;
			case 54:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_five_four));
				break;
			case 55:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_five_five));
				break;
			case 56:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_five_six));
				break;
			case 61:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_six_one));
				break;
			case 62:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_six_two));

				break;
			case 63:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_six_three));
				break;
			case 64:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_six_four));
				break;
			case 65:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_six_five));
				break;
			case 66:
				holder.colorIv.setBackground(getResources().getDrawable(
						R.color.palette_six_six));
				break;

			default:
				break;
			}

			return convertView;
		}
	}

	// 设置actionBar
	public void setActionBar() {
		Button leftfirstBtn, leftsecondBtn, rightfirstBtn, rightsecondBtn, rightthirdBtn;
		TextView title;

		leftfirstBtn = BindView(R.id.leftfirst_btn);
		leftsecondBtn = BindView(R.id.leftsecond_btn);
		rightfirstBtn = BindView(R.id.rightfirst_btn);
		rightsecondBtn = BindView(R.id.rightsecond_btn);
		rightthirdBtn = BindView(R.id.rightthird_btn);

		title = BindView(R.id.title);

		leftfirstBtn.setVisibility(View.GONE);
		leftfirstBtn.setText(R.string.item_actionbar_menu);
		leftsecondBtn.setVisibility(View.VISIBLE);
		leftsecondBtn.setText(R.string.item_actionbar_home);

		rightfirstBtn.setText(R.string.actionBar_new);

		rightsecondBtn.setText(R.string.actionBar_saveAs);
		rightthirdBtn.setVisibility(View.GONE);
		rightthirdBtn.setText(R.string.actionBar_save);
		rightfirstBtn.setVisibility(View.GONE);
		rightsecondBtn.setVisibility(View.GONE);
		title.setText(R.string.menufragment_layout);

		leftfirstBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (!menuboo) {
					showMenuPopupWindow(v);
					menuboo = !menuboo;
				} else {
					menuPopupWindow.dismiss();
					menuboo = !menuboo;
				}

			}

		});

		leftsecondBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				allShengDialog = new AllShengDialog(
						AbsoluteQuaLayoutActivity.this,
						getString(R.string.dialog_tishi),
						getString(R.string.dialog_del),
						getString(R.string.dialog_yes),
						getString(R.string.dilog_no));

				allShengDialog
						.setClicklistener(new AllShengDialog.ClickListenerInterface() {

							@Override
							public void OK() {
								// 数据
								String folderName;
								String fileName;
								String appFilePath = Environment
										.getExternalStorageDirectory()
										+ "/"
										+ "AllShengMedical";
								List<FileBean> fileBeans2;

								// 读取
								SharedPreferences preferences = getSharedPreferences(
										BaseApplication.FILEMANGER_HISTORYARRAYLIST,
										MODE_PRIVATE);
								String json = preferences.getString("fileBean",
										null);
								fileBeans2 = new ArrayList<FileBean>();
								if (json != null) {
									Gson gson = new Gson();
									Type type = new TypeToken<List<FileBean>>() {
									}.getType();

									fileBeans2 = gson.fromJson(json, type);
									for (int i = 0; i < fileBeans2.size(); i++) {
										Log.d("读sp", fileBeans2.get(i)
												.getFoldName()
												+ ":"
												+ fileBeans2.get(i)
														.getFileName()
												+ ","
												+ fileBeans2.get(i)
														.getCreateTime());
									}
								}

								folderName = (String) SharedPreferencesUtils
										.get(AbsoluteQuaLayoutActivity.this,
												BaseApplication.FILEMANGER_PREPAREFOLDERPATH,
												"0");
								fileName = (String) SharedPreferencesUtils
										.get(AbsoluteQuaLayoutActivity.this,
												BaseApplication.FILEMANGER_PREPAREFILENAME,
												"0");

								String path = appFilePath + "/" + folderName;

								File file = new File(path + "/" + fileName);
								if (file.isFile() && file.exists()) {// 路径为文件且不为空则进行删除
									file.delete();// 文件删除

								}
								for (FileBean bean : fileBeans2) {
									if (fileName.equals(bean.getFileName())) {
										if (folderName.equals(bean
												.getFoldName())) {
											fileBeans2.remove(bean);
											break;
										}

									}
								}

								// 写回sp
								// 写
								SharedPreferences.Editor editor = getSharedPreferences(
										BaseApplication.FILEMANGER_HISTORYARRAYLIST,
										MODE_PRIVATE).edit();
								Gson gson = new Gson();
								String json2 = gson.toJson(fileBeans2);
								Log.d("gson写", "saved json is " + json2);
								editor.putString("fileBean", json2);
								editor.commit();

								BaseApplication.getInstance().finishAll();
								Intent intent = new Intent(
										AbsoluteQuaLayoutActivity.this,
										MainMenuActivity.class);
								startActivity(intent);
								allShengDialog.dismiss();
							}

							@Override
							public void Cancle() {
								allShengDialog.dismiss();
							}

						});
				allShengDialog.show();

				//
			}
		});

		rightfirstBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// ByAlert.alert("New");
				Intent intent = new Intent(AbsoluteQuaLayoutActivity.this,
						FileManagerActivity.class);
				startActivity(intent);
			}
		});
		rightsecondBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// ByAlert.alert("Save As");
				Intent intent = new Intent(AbsoluteQuaLayoutActivity.this,
						FileManagerActivity.class);
				startActivity(intent);
			}
		});
		rightthirdBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// savePopupWindow(v);
			}

		});

	}

	// 获取当前时间的方法
	public void setSystemTime() {

		TextView date, fileName;
		date = BindView(R.id.date);
		fileName = BindView(R.id.file_name);

		// 获取系统时间
		SimpleDateFormat sdfDate = new SimpleDateFormat("MM dd,yyyy");
		date.setText(sdfDate.format(new Date()));

		// 文件路径置空
		fileName.setText(SharedPreferencesUtils.get(this,
				BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "")
				+ "/"
				+ SharedPreferencesUtils.get(this,
						BaseApplication.FILEMANGER_PREPAREFILENAME, ""));

	}

	// menu的弹出窗口
	private void showMenuPopupWindow(View v) {

		if (null == menuPopupWindow || !menuPopupWindow.isShowing()) {
			View contentView = LayoutInflater.from(this).inflate(
					R.layout.fragment_new_basicinformation_menu, null);

			menuPopupWindow = new PopupWindow(contentView,
					LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
			menuPopupWindow.setBackgroundDrawable(new BitmapDrawable());
			menuPopupWindow.setTouchable(true);
			menuPopupWindow.setOutsideTouchable(true);
			menuPopupWindow.showAsDropDown(v, -40, -3);

			TextView basicInformationTv, layoutTv, methodTv, previewTv;
			basicInformationTv = (TextView) contentView
					.findViewById(R.id.basicInformationTv);
			layoutTv = (TextView) contentView.findViewById(R.id.layoutTv);
			methodTv = (TextView) contentView.findViewById(R.id.methodTv);
			previewTv = (TextView) contentView.findViewById(R.id.previewTv);

			basicInformationTv.setBackground(getResources().getDrawable(
					R.color.darkBlue));
			basicInformationTv.setTextColor(this.getResources().getColor(
					R.color.white));
			layoutTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					ByAlert.alert("跳转页面layout");

				}
			});
			methodTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					ByAlert.alert("跳转页面method");
				}
			});
			previewTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					ByAlert.alert("跳转页面preview");
				}
			});

		} else {
			menuPopupWindow.dismiss();
			menuboo = !menuboo;
		}

	}

	// 设置bottom布局
	public void setBottomView() {
		Button bottomLeftFistBtn, bottomCenterBtn, bottomRightBtn;

		bottomLeftFistBtn = BindView(R.id.bottomLeftFistBtn);
		bottomCenterBtn = BindView(R.id.bottomCenterBtn);
		bottomRightBtn = BindView(R.id.bottomRightBtn);

		bottomLeftFistBtn.setVisibility(View.VISIBLE);
		// bottomCenterBtn.setVisibility(View.VISIBLE);
		bottomRightBtn.setVisibility(View.VISIBLE);

		bottomLeftFistBtn.setText(R.string.bottomView_back);
		// TODO 这个button的文字不确定暂时用A代替
		bottomCenterBtn.setText("A"); // 不确定！！！！！！！
		bottomRightBtn.setText(R.string.bottomView_next);

		bottomLeftFistBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Intent intent = new Intent(AbsoluteQuaLayoutActivity.this,
						LayoutOneActivity.class);
				startActivity(intent);
				finish();

			}
		});

		bottomCenterBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				ByAlert.alert("A");

			}
		});
		bottomRightBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Boolean nullflag = false;
				for (int i = 0; i < 16; i++) {
					if (!TextUtils.isEmpty(dataSourceListBlock1.get(i).get(
							"item_image")
							+ "")) {
						nullflag = true;
					}
					if (!TextUtils.isEmpty(dataSourceListBlock2.get(i).get(
							"item_image")
							+ "")) {
						nullflag = true;
					}
				}
				if (!nullflag) {

					ByAlert.alert(getString(R.string._Genelasthaveone));
					return;
				}
				// 创建文件
				String folderName = SharedPreferencesUtils.get(
						AbsoluteQuaLayoutActivity.this,
						BaseApplication.FILEMANGER_PREPAREFOLDERPATH, "0")
						+ "";
				String fileName = SharedPreferencesUtils.get(
						AbsoluteQuaLayoutActivity.this,
						BaseApplication.FILEMANGER_PREPAREFILENAME, "0")
						+ "";

				StringBuffer content = new StringBuffer();

				content.append("\r\n" + "\r\n" + "dataSourceListBlock1"
						+ "\r\n");

				for (int i = 0; i < 16; i++) {
					content.append("\r\n" + "item_image: "
							+ dataSourceListBlock1.get(i).get("item_image"));
					content.append("\r\n" + "item_text: "
							+ dataSourceListBlock1.get(i).get("item_text"));
					content.append("\r\n" + "item_selected: "
							+ dataSourceListBlock1.get(i).get("item_selected"));

					content.append("\r\n" + "item_null: "
							+ dataSourceListBlock1.get(i).get("item_null"));
					content.append("\r\n" + "item_aisle: "
							+ dataSourceListBlock1.get(i).get("item_aisle"));
					content.append("\r\n" + "item_type: "
							+ dataSourceListBlock1.get(i).get("item_type"));

				}

				content.append("\r\n" + "\r\n" + "dataSourceListBlock2"
						+ "\r\n");

				for (int i = 0; i < 16; i++) {
					content.append("\r\n" + "item_image: "
							+ dataSourceListBlock2.get(i).get("item_image"));
					content.append("\r\n" + "item_text: "
							+ dataSourceListBlock2.get(i).get("item_text"));
					content.append("\r\n" + "item_selected: "
							+ dataSourceListBlock2.get(i).get("item_selected"));

					content.append("\r\n" + "item_null: "
							+ dataSourceListBlock2.get(i).get("item_null"));
					content.append("\r\n" + "item_aisle: "
							+ dataSourceListBlock2.get(i).get("item_aisle"));
					content.append("\r\n" + "item_type: "
							+ dataSourceListBlock2.get(i).get("item_type"));

				}
				fileManagerUtil.createFIle(folderName, fileName);
				fileManagerUtil.writeFile(folderName, fileName, content + "",
						true);

				Intent intent = new Intent(AbsoluteQuaLayoutActivity.this,
						MethodsActivity1.class);
				intent.putExtra("activityLayoutTableBeans",
						activityLayoutTableBeans);
				startActivity(intent);
			

			}
		});
	}

	private void initTableLv() {
		targetTableAdapter = new TargetTableAdapter(activityLayoutTableBeans);
		targetGenesLv.setAdapter(targetTableAdapter);

	}

	private void initSampleLv() {
		LayoutInflater infla = LayoutInflater.from(this);
		View footView = infla.inflate(
				R.layout.item_listview_layout_addfootview, null);
		sampleBeans = new ArrayList<SampleBean>();

		// for (LayoutTableBean bean : activityLayoutTableBeans) {
		// if (bean.isSelected()) {
		// sampleBeans = bean.getSampleBeans();
		// }
		// }

		for (int i = 1; i <= 32; i++) {
			sampleBeans.add(new SampleBean("Sample" + i, false));
		}

		sampleAdapter = new SampleAdapter(sampleBeans);
		// for (LayoutTableBean bean : activityLayoutTableBeans) {
		// if (bean.isSelected()) {
		//
		// if (sampleLv.getCount() < bean.getSampleBeans().size() + 1) {
		//
		// }
		//
		// }
		// }
		sampleLv.setAdapter(sampleAdapter);
		// for(int i= 1 ;i<=16;i++){
		// sampleAdapter.addNewSample();
		//
		// }
		// sampleAdapter.notifyDataSetChanged();
		// sampleLvLine.setVisibility(View.VISIBLE);

		// 不要add了
		/*
		 * // 如果创建过就不加footView了 if (!firstCreatList) {
		 * sampleLv.addFooterView(footView); firstCreatList = true;
		 * 
		 * }
		 * 
		 * footView.setOnClickListener(new OnClickListener() {
		 * 
		 * @Override public void onClick(View v) {
		 * 
		 * sampleAdapter.addNewSample(); sampleAdapter.notifyDataSetChanged();
		 * sampleLv.setSelection(sampleAdapter.getCount());
		 * 
		 * } });
		 */

	}

	private void ifTargetSelected() {
		targetSelected = false;
		for (LayoutTableBean layoutTableBean : activityLayoutTableBeans) {

			if (layoutTableBean.isSelected()) {
				targetSelected = true;
			}

		}

	}

	public class SampleAdapter extends BaseAdapter {

		private ArrayList<SampleBean> sampleBeans;

		public SampleAdapter(ArrayList<SampleBean> sampleBeans) {
			super();
			this.sampleBeans = sampleBeans;
		}

		// public void addNewSample() {
		// int count = getCount() + 1;
		// String sampleName = "Sample ";
		// // sampleBeans.add(new SampleBean(sampleName + count, false));
		// for (LayoutTableBean bean : activityLayoutTableBeans) {
		// if (bean.isSelected()) {
		// bean.getSampleBeans().add(
		// (new SampleBean(sampleName + count, false)));
		// }
		// }
		// notifyDataSetChanged();
		//
		// }

		class ViewHolder {

			TextView sampleNameTv;
			LinearLayout line;

		}

		@Override
		public int getCount() {
			// return sampleBeans != null ? sampleBeans.size() : 0;
			return 32;
		}

		@Override
		public Object getItem(int position) {
			return sampleBeans != null ? sampleBeans.get(position) : null;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(final int position, View convertView,
				final ViewGroup parent) {
			final ViewHolder holder;
			if (convertView == null) {
				holder = new ViewHolder();
				convertView = LayoutInflater.from(
						AbsoluteQuaLayoutActivity.this).inflate(
						R.layout.item_listview_sampleline, null);

				holder.sampleNameTv = (TextView) convertView
						.findViewById(R.id.sampleNameTv);

				holder.line = (LinearLayout) convertView
						.findViewById(R.id.line);

				convertView.setTag(holder);
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.sampleNameTv.setText(sampleBeans.get(position)
					.getSampleName());
			holder.sampleNameTv.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					Intent keyBoardIntent = new Intent(
							AbsoluteQuaLayoutActivity.this,
							KeyboardActivity.class);
					samplePosition = position;
					keyBoardIntent.putExtra("folderName", holder.sampleNameTv
							.getText().toString());
					keyBoardIntent.putExtra("title", getText(R.string.sample_name));

					startActivityForResult(keyBoardIntent, 101);

				}
			});
			holder.line.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {

					for (SampleBean sampleBean : sampleBeans) {
						sampleBean.setSelected(false);
					}

					sampleBeans.get(position).setSelected(true);
					notifyDataSetChanged();
				}
			});

			if (sampleBeans.get(position).getSelected()) {
				holder.line.setBackground(getResources().getDrawable(
						R.color.darkBlue));
			} else {
				holder.line.setBackground(getResources().getDrawable(
						R.color.white));
			}

			return convertView;
		}
	}

	private void initDragGridView() {
		// dataSourceListBlock1 先不做dataSourceListBlock2

		for (int i = 0; i < 16; i++) {
			HashMap<String, Object> itemHashMap = new HashMap<String, Object>();
			// 颜色
			itemHashMap.put("item_image", "");
			// 名字
			itemHashMap.put("item_text", "1Block" + Integer.toString(i));
			// 选中状态
			itemHashMap.put("item_selected", false);

			dataSourceListBlock1.add(itemHashMap);

		}
		for (int i = 0; i < 16; i++) {
			HashMap<String, Object> itemHashMap = new HashMap<String, Object>();
			// 颜色
			itemHashMap.put("item_image", "");
			// 名字
			itemHashMap.put("item_text", "2Block " + Integer.toString(i));
			// 选中状态
			itemHashMap.put("item_selected", false);

			dataSourceListBlock2.add(itemHashMap);
		}
		dataSourceListBlockToShow.clear();
		dataSourceListBlockToShow.addAll(dataSourceListBlock1);
		mSimple1Adapter = new DragGridViewAdapter(dataSourceListBlockToShow);

		dragGridView.setAdapter(mSimple1Adapter);
		dragGridView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {

				if (block == 1) {
					if ((Boolean) dataSourceListBlock1.get(position).get(
							"item_selected")) {
						dataSourceListBlock1.get(position).put("item_selected",
								false);
						dataSourceListBlockToShow.clear();
						dataSourceListBlockToShow.addAll(dataSourceListBlock1);

					} else {
						dataSourceListBlock1.get(position).put("item_selected",
								true);
						dataSourceListBlockToShow.clear();
						dataSourceListBlockToShow.addAll(dataSourceListBlock1);

					}
					mSimple1Adapter.notifyDataSetChanged();
				} else if (block == 2) {
					if ((Boolean) dataSourceListBlock2.get(position).get(
							"item_selected")) {
						dataSourceListBlock2.get(position).put("item_selected",
								false);
						dataSourceListBlockToShow.clear();
						dataSourceListBlockToShow.addAll(dataSourceListBlock2);

					} else {
						dataSourceListBlock2.get(position).put("item_selected",
								true);
						dataSourceListBlockToShow.clear();
						dataSourceListBlockToShow.addAll(dataSourceListBlock2);

					}
					mSimple1Adapter.notifyDataSetChanged();
				}

			}
		});

		dragGridView.setOnChangeListener(new OnChanageListener() {

			@Override
			public void onChange(int from, int to) {
				if (block == 1) {
					HashMap<String, Object> temp = dataSourceListBlock1
							.get(from);
					// 直接交互item
					// dataSourceList.set(from, dataSourceList.get(to));
					// dataSourceList.set(to, temp);

					// 这里的处理需要注意下
					if (from < to) {
						for (int i = from; i < to; i++) {
							Collections.swap(dataSourceListBlock1, i, i + 1);
						}
					} else if (from > to) {
						for (int i = from; i > to; i--) {
							Collections.swap(dataSourceListBlock1, i, i - 1);
						}
					}

					dataSourceListBlock1.set(to, temp);
					dataSourceListBlockToShow.clear();
					dataSourceListBlockToShow.addAll(dataSourceListBlock1);

					mSimple1Adapter.notifyDataSetChanged();
				} else if (block == 2) {
					HashMap<String, Object> temp = dataSourceListBlock2
							.get(from);
					// 直接交互item
					// dataSourceList.set(from, dataSourceList.get(to));
					// dataSourceList.set(to, temp);

					// 这里的处理需要注意下
					if (from < to) {
						for (int i = from; i < to; i++) {
							Collections.swap(dataSourceListBlock2, i, i + 1);
						}
					} else if (from > to) {
						for (int i = from; i > to; i--) {
							Collections.swap(dataSourceListBlock2, i, i - 1);
						}
					}

					dataSourceListBlock2.set(to, temp);
					dataSourceListBlockToShow.clear();
					dataSourceListBlockToShow.addAll(dataSourceListBlock2);

					mSimple1Adapter.notifyDataSetChanged();
				}

			}
		});

	}

	public class DragGridViewAdapter extends BaseAdapter {
		List<HashMap<String, Object>> dataSourceListBlock = new ArrayList<HashMap<String, Object>>();

		public DragGridViewAdapter(
				List<HashMap<String, Object>> dataSourceListBlock) {
			super();
			this.dataSourceListBlock = dataSourceListBlock;
		}

		public void changeList(List<HashMap<String, Object>> dataSourceListBlock) {

			this.dataSourceListBlock = dataSourceListBlock;
			notifyDataSetChanged();
		}

		class ViewHolder {

			LinearLayout line, textViewLine;
			ImageView item_image;
			TextView item_text, aisle1, aisle2, aisle3, aisle4;

		}

		@Override
		public int getCount() {
			return dataSourceListBlock != null ? dataSourceListBlock.size() : 0;
		}

		@Override
		public Object getItem(int position) {
			return dataSourceListBlock != null ? dataSourceListBlock
					.get(position) : null;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			final ViewHolder holder;
			if (convertView == null) {
				holder = new ViewHolder();
				convertView = LayoutInflater.from(
						AbsoluteQuaLayoutActivity.this).inflate(
						R.layout.item_layout2_grid, null);

				holder.line = (LinearLayout) convertView
						.findViewById(R.id.line);
				holder.item_image = (ImageView) convertView
						.findViewById(R.id.item_image);
				holder.item_text = (TextView) convertView
						.findViewById(R.id.item_text);
				holder.aisle1 = (TextView) convertView
						.findViewById(R.id.aisle1);
				holder.aisle2 = (TextView) convertView
						.findViewById(R.id.aisle2);
				holder.aisle3 = (TextView) convertView
						.findViewById(R.id.aisle3);
				holder.aisle4 = (TextView) convertView
						.findViewById(R.id.aisle4);
				holder.textViewLine = (LinearLayout) convertView
						.findViewById(R.id.textViewLine);

				convertView.setTag(holder);
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			holder.aisle1.setVisibility(View.INVISIBLE);
			holder.aisle2.setVisibility(View.INVISIBLE);
			holder.aisle3.setVisibility(View.INVISIBLE);
			holder.aisle4.setVisibility(View.INVISIBLE);
			holder.textViewLine.setVisibility(View.INVISIBLE);
			holder.item_image.setBackground(getResources().getDrawable(
					R.color.white));

			if (dataSourceListBlock.get(position).get("item_null") != null) {
				if ((Boolean) dataSourceListBlock.get(position)
						.get("item_null")) {
					holder.aisle1.setVisibility(View.INVISIBLE);
					holder.aisle2.setVisibility(View.INVISIBLE);
					holder.aisle3.setVisibility(View.INVISIBLE);
					holder.aisle4.setVisibility(View.INVISIBLE);
					holder.textViewLine.setVisibility(View.INVISIBLE);
					holder.item_image.setBackground(getResources().getDrawable(
							R.color.white));
				}
			}

			if (dataSourceListBlock.get(position).get("item_aisle") != null) {
				if (!TextUtils.isEmpty(dataSourceListBlock.get(position).get(
						"item_aisle")
						+ "")) {
					int aisleNum = (Integer) dataSourceListBlock.get(position)
							.get("item_aisle");
					holder.textViewLine.setVisibility(View.VISIBLE);
					holder.aisle1.setVisibility(View.VISIBLE);
					holder.aisle2.setVisibility(View.VISIBLE);
					holder.aisle3.setVisibility(View.VISIBLE);
					holder.aisle4.setVisibility(View.VISIBLE);
					switch (aisleNum) {
					case 1:
						setcolor(holder.aisle1, position, holder.textViewLine);
						holder.aisle2.setBackground(getResources().getDrawable(
								R.color.white));
						holder.aisle3.setBackground(getResources().getDrawable(
								R.color.white));
						holder.aisle4.setBackground(getResources().getDrawable(
								R.color.white));

						break;
					case 2:
						holder.aisle1.setBackground(getResources().getDrawable(
								R.color.white));
						setcolor(holder.aisle2, position, holder.textViewLine);
						holder.aisle3.setBackground(getResources().getDrawable(
								R.color.white));
						holder.aisle4.setBackground(getResources().getDrawable(
								R.color.white));

						break;

					case 3:
						holder.aisle1.setBackground(getResources().getDrawable(
								R.color.white));
						holder.aisle2.setBackground(getResources().getDrawable(
								R.color.white));
						setcolor(holder.aisle3, position, holder.textViewLine);
						holder.aisle4.setBackground(getResources().getDrawable(
								R.color.white));
						break;

					case 4:
						holder.aisle1.setBackground(getResources().getDrawable(
								R.color.white));
						holder.aisle2.setBackground(getResources().getDrawable(
								R.color.white));
						holder.aisle3.setBackground(getResources().getDrawable(
								R.color.white));
						setcolor(holder.aisle4, position, holder.textViewLine);
						break;

					default:
						break;
					}

				} else {
					holder.textViewLine.setVisibility(View.INVISIBLE);
					holder.aisle1.setVisibility(View.INVISIBLE);
					holder.aisle2.setVisibility(View.INVISIBLE);
					holder.aisle3.setVisibility(View.INVISIBLE);
					holder.aisle4.setVisibility(View.INVISIBLE);
				}
			}
			if ((Boolean) dataSourceListBlock.get(position)
					.get("item_selected")) {
				holder.line.setBackground(getResources().getDrawable(
						R.color.darkBlue));
			} else {
				holder.line.setBackground(getResources().getDrawable(
						R.color.white));
			}

			// map.put("item_type", "positive");

			if ("sample".equals(dataSourceListBlock.get(position).get(
					"item_type"))) {
				holder.item_image.setBackgroundColor(Color
						.parseColor("#ff2d55"));
			} else if ("standard".equals(dataSourceListBlock.get(position).get(
					"item_type"))) {
				holder.item_image.setBackgroundColor(Color
						.parseColor("#fd9727"));
			} else if ("positive".equals(dataSourceListBlock.get(position).get(
					"item_type"))) {
				holder.item_image.setBackgroundColor(Color
						.parseColor("#ff00a9"));
			} else if ("negative".equals(dataSourceListBlock.get(position).get(
					"item_type"))) {
				holder.item_image.setBackgroundColor(Color
						.parseColor("#159588"));
			} else if (dataSourceListBlock.get(position).get("item_image") == null) {
				holder.item_image.setBackground(getResources().getDrawable(
						R.color.white));
			} else if ("".equals(dataSourceListBlock.get(position).get(
					"item_type"))) {
				holder.item_image.setBackground(getResources().getDrawable(
						R.color.white));
			} else {
				holder.item_image.setBackground(getResources().getDrawable(
						R.color.white));
			}

			// if
			// ("".equals(dataSourceListBlock.get(position).get("item_image")))
			// {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.white));
			// } else if ("11".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_one));
			// } else if ("12".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_two));
			// } else if ("13".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_three));
			// } else if ("14".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_four));
			// } else if ("15".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_five));
			// } else if ("16".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_one_six));
			// } else if ("21".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_one));
			// } else if ("22".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_two));
			// } else if ("23".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_three));
			// } else if ("24".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_four));
			// } else if ("25".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_five));
			// } else if ("26".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_two_six));
			// } else if ("31".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_one));
			// } else if ("32".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_two));
			// } else if ("33".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_three));
			// } else if ("34".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_four));
			// } else if ("35".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_five));
			// } else if ("36".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_three_six));
			// } else if ("41".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_one));
			// } else if ("42".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_two));
			// } else if ("43".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_three));
			// } else if ("44".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_four));
			// } else if ("45".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_five));
			// } else if ("46".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_four_six));
			// } else if ("51".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_one));
			// } else if ("52".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_two));
			// } else if ("53".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_three));
			// } else if ("54".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_four));
			// } else if ("55".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_five));
			// } else if ("56".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_five_six));
			// } else if ("61".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_one));
			// } else if ("62".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_two));
			// } else if ("63".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_three));
			// } else if ("64".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_four));
			// } else if ("65".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_five));
			// } else if ("66".equals(dataSourceListBlock.get(position).get(
			// "item_image"))) {
			// holder.item_image.setBackground(getResources().getDrawable(
			// R.color.palette_six_six));
			// }
			holder.item_text.setText(dataSourceListBlock.get(position).get(
					"item_text")
					+ "");

			return convertView;
		}

		private void setcolor(TextView aisle, int position,
				LinearLayout textViewLine) {
			if ("".equals(dataSourceListBlock.get(position).get("item_image"))) {
				aisle.setBackground(getResources().getDrawable(R.color.white));
				textViewLine.setVisibility(View.INVISIBLE);
			} else if ("11".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_one_one));
			} else if ("12".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_one_two));
			} else if ("13".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_one_three));
			} else if ("14".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_one_four));
			} else if ("15".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_one_five));
			} else if ("16".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_one_six));
			} else if ("21".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_two_one));
			} else if ("22".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_two_two));
			} else if ("23".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_two_three));
			} else if ("24".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_two_four));
			} else if ("25".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_two_five));
			} else if ("26".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_two_six));
			} else if ("31".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_three_one));
			} else if ("32".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_three_two));
			} else if ("33".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_three_three));
			} else if ("34".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_three_four));
			} else if ("35".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_three_five));
			} else if ("36".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_three_six));
			} else if ("41".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_four_one));
			} else if ("42".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_four_two));
			} else if ("43".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_four_three));
			} else if ("44".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_four_four));
			} else if ("45".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_four_five));
			} else if ("46".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_four_six));
			} else if ("51".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_five_one));
			} else if ("52".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_five_two));
			} else if ("53".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_five_three));
			} else if ("54".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_five_four));
			} else if ("55".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_five_five));
			} else if ("56".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_five_six));
			} else if ("61".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_six_one));
			} else if ("62".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_six_two));
			} else if ("63".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_six_three));
			} else if ("64".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_six_four));
			} else if ("65".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_six_five));
			} else if ("66".equals(dataSourceListBlock.get(position).get(
					"item_image"))) {
				aisle.setBackground(getResources().getDrawable(
						R.color.palette_six_six));
			} else if (dataSourceListBlock.get(position).get("item_image") == null) {
				aisle.setBackground(getResources().getDrawable(R.color.white));
				textViewLine.setVisibility(View.INVISIBLE);

			} else {
				aisle.setBackground(getResources().getDrawable(R.color.white));
				textViewLine.setVisibility(View.INVISIBLE);
			}

		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {

		// 点击Sample名称编辑，返回时传数据
		if (requestCode == 101 && resultCode == 201) {
			Boolean bool = true;
			if ("".equals(data.getStringExtra("result"))) {
				bool = false;
			} else {
				for (int i = 0; i < sampleBeans.size(); i++) {
					if (sampleBeans.get(i).getSampleName()
							.equals(data.getStringExtra("result") + "")) {
						bool = false;
					}
				}
			}
			if (bool) {

				for (int i = 0; i < 16; i++) {
					if (sampleBeans
							.get(samplePosition)
							.getSampleName()
							.equals(dataSourceListBlock1.get(i)
									.get("item_text").toString())) {
						dataSourceListBlock1.get(i).put("item_text",
								data.getStringExtra("result") + "");
					}
					if (sampleBeans
							.get(samplePosition)
							.getSampleName()
							.equals(dataSourceListBlock2.get(i)
									.get("item_text").toString())) {
						dataSourceListBlock2.get(i).put("item_text",
								data.getStringExtra("result") + "");
					}
				}
				mSimple1Adapter.notifyDataSetChanged();
				sampleBeans.get(samplePosition).setSampleName(
						data.getStringExtra("result") + "");
				sampleAdapter.notifyDataSetChanged();

			} else {
				ByAlert.alert(getString(R.string.absolutelayout_nameerror));

			}

		}
		// 点击Sample名称编辑，返回时不传数据
		if (requestCode == 101 && resultCode == 202) {

		}

	}

	// 配置数字键盘的popupwindow
	private void numberKeyBoardPopupWindow(View v) {
		View conteView = LayoutInflater.from(this).inflate(
				R.layout.item_numkeyboard, null);

		final EditText showTv;
		TextView num0Tv, num1Tv, num2Tv, num3Tv, num4Tv, num5Tv, num6Tv, num7Tv, num8Tv, num9Tv, num10Tv, cancelTv, confirmTv;
		showTv = (EditText) conteView.findViewById(R.id.showTv);
		num0Tv = (TextView) conteView.findViewById(R.id.num0Tv);
		num1Tv = (TextView) conteView.findViewById(R.id.num1Tv);
		num2Tv = (TextView) conteView.findViewById(R.id.num2Tv);
		num3Tv = (TextView) conteView.findViewById(R.id.num3Tv);
		num4Tv = (TextView) conteView.findViewById(R.id.num4Tv);
		num5Tv = (TextView) conteView.findViewById(R.id.num5Tv);
		num6Tv = (TextView) conteView.findViewById(R.id.num6Tv);
		num7Tv = (TextView) conteView.findViewById(R.id.num7Tv);
		num8Tv = (TextView) conteView.findViewById(R.id.num8Tv);
		num9Tv = (TextView) conteView.findViewById(R.id.num9Tv);
		confirmTv = (TextView) conteView.findViewById(R.id.confirmTv);
		cancelTv = (TextView) conteView.findViewById(R.id.cancelTv);

		final PopupWindow numberKeyBoardPopupWindow = new PopupWindow(
				conteView, LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT, true);

		cancelTv.setText(".");

		confirmTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				DecimalFormat fnum = new DecimalFormat("##0.00000000");
				if (Double.parseDouble(fnum.format(Double.parseDouble(showTv
						.getText() + ""))
						+ "") == 0) {
					ByAlert.alert(getString(R.string.absolutelayout__0_error));
					return;
				}

				initialConcentrationTv.setText(fnum.format(Double
						.parseDouble(showTv.getText() + "")));
				numberKeyBoardPopupWindow.dismiss();
			}
		});

		cancelTv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (showTv.getText().toString().contains(".")) {

				} else {
					showTv.setText(showTv.getText().append("."));
					Selection.setSelection(showTv.getText(), showTv.getText()
							.length());
				}

			}
		});
		num0Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("0"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});
		num1Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("1"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});

		num2Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("2"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});
		num3Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("3"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});

		num3Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("3"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});
		num4Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("4"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});
		num5Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("5"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});

		num6Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("6"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});

		num7Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("7"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});
		num8Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("8"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});

		num9Tv.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				showTv.setText(showTv.getText().append("9"));
				Selection.setSelection(showTv.getText(), showTv.getText()
						.length());

			}
		});

		numberKeyBoardPopupWindow.setTouchable(true);

		numberKeyBoardPopupWindow.setTouchInterceptor(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {

				return false;
				// 这里如果返回true的话，touch事件将被拦截
				// 拦截后 PopupWindow的onTouchEvent不被调用，这样点击外部区域无法dismiss
			}

		});

		numberKeyBoardPopupWindow.setBackgroundDrawable(new BitmapDrawable());
		numberKeyBoardPopupWindow.setTouchable(true);
		numberKeyBoardPopupWindow.setOutsideTouchable(true);
		numberKeyBoardPopupWindow.showAtLocation(v, Gravity.CENTER, 0, -15);

	}

}
